﻿using System.Windows;

namespace Notoric.Gui.Windows
{
    /// <summary>
    /// Interaction logic for EditPersonDialog.xaml
    /// </summary>
    public partial class EditPersonDialog : Window
    {
        #region Constructors

        /// <summary>
        /// Initializes a new instance of the <see cref="EditPersonDialog"/> class.
        /// </summary>
        public EditPersonDialog()
        {
            InitializeComponent();
            PART_FirstName.Focus();
        }

        #endregion

        #region Event Handlers

        /// <summary>
        /// Handles the Click event of the PART_OK control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="System.Windows.RoutedEventArgs"/> instance containing the event data.</param>
        private void PART_OK_Click(object sender, RoutedEventArgs e)
        {
            var person = (ViewModel.Elements.Person)DataContext;
            person.CommitChanges();

            this.DialogResult = true;
        }

        /// <summary>
        /// Handles the Click event of the PART_Cancel control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="System.Windows.RoutedEventArgs"/> instance containing the event data.</param>
        private void PART_Cancel_Click(object sender, RoutedEventArgs e)
        {
            var person = (ViewModel.Elements.Person)DataContext;
            person.AbortChanges();

            this.DialogResult = false;
        }

        #endregion
    }
}
